package nongchang.kuaijiecaifu.com.ncapp_android.ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import ezy.lite.util.DateTime;
import ezy.lite.util.UI;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.adapter.ItemAdapter;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.Balance;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.Laisee;

/**
 * Created by Administrator on 2016/4/26 0026.
 */
public class MyBalanceListAdapter extends ItemAdapter<Balance, MyBalanceListAdapter.BalanceViewHolder> {
    private Context context;

    public MyBalanceListAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public BalanceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new BalanceViewHolder(inflate(R.layout.item_my_balance, parent));
    }

    @Override
    public void onBindViewHolder(BalanceViewHolder holder, int position) {
        Balance item = getItem(position);
        holder.txt_content.setText(item.content);
        holder.txt_time.setText(DateTime.toDate(item.time * 1000));
        holder.txt_money.setText("余额：￥"+item.money);
        if(item.type==0){
            holder.txt_spend_money.setText("+"+item.spendMoney);
            holder.txt_spend_money.setTextColor(0xFF2ABAAB);
        }else{
            holder.txt_spend_money.setText("-"+item.spendMoney);
            holder.txt_spend_money.setTextColor(Color.RED);
        }
        holder.txt_title.setText(item.title);
    }


    static class BalanceViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.txt_money)
        TextView txt_money;
        @BindView(R.id.txt_content)
        TextView txt_content;
        @BindView(R.id.txt_time)
        TextView txt_time;
        @BindView(R.id.txt_spend_money)
        TextView txt_spend_money;
        @BindView(R.id.txt_title)
        TextView txt_title;
        public BalanceViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
//                    ContextUtil.startActivity(v.getContext(), LifeShopActivity.class);
                }
            });
        }

    }
}
